Skip to content

[fix](nereids) stabilize the flaky shuffle_left_join regression test#65769

Open
924060929 wants to merge 1 commit into
apache:masterfrom
924060929:fix_flaky_shuffle_left_join
Open

[fix](nereids) stabilize the flaky shuffle_left_join regression test#65769
924060929 wants to merge 1 commit into
apache:masterfrom
924060929:fix_flaky_shuffle_left_join

Conversation

@924060929

Copy link
Copy Markdown
Contributor

What problem does this PR solve?

The nereids_syntax_p0/distribute/shuffle_left_join regression test is flaky.

With the nereids distribute planner enabled, the join in this suite can be
planned either as INNER JOIN(PARTITIONED) or as a left-to-right
INNER JOIN(BUCKET_SHUFFLE) — the aggregated left side shuffled onto the right
table's storage buckets — and the two candidates are chosen by cost. That cost
is not stable during the test:

  • the scan row count is reported asynchronously after the insert, so an
    unreported count clamps to 1 (which favors a partitioned shuffle), while the
    real count favors a bucket shuffle;
  • the bucket-shuffle downgrade gate (isBucketShuffleDownGrade) turns bucket
    shuffle back into a partitioned shuffle when the bucket count is small
    relative to the instance count, so the plan also depends on the number of
    backends.

As a result the asserted plan flips between INNER JOIN(PARTITIONED) and
INNER JOIN(BUCKET_SHUFFLE) depending on timing and cluster topology.

The suite is meant to assert the left-to-right bucket shuffle, which saves one
exchange versus a plain partitioned shuffle. This PR restores that assertion and
makes it deterministic:

  • analyze table ... with sync fixes the row count instead of racing the async
    tablet report (the count is then read from the collected column stats);
  • set bucket_shuffle_downgrade_ratio=0 removes the dependency on the number of
    backends.

Verified on a 4-backend cluster: the suite now stably produces
INNER JOIN(PARTITIONED) for the legacy-planner leg and
INNER JOIN(BUCKET_SHUFFLE) for the distribute-planner leg across parallelism
1/4/8 and both before/after stats reporting; the suite was run 3 times, all
green.

Release note

None

Check List (For Committer)

  • Regression test
  • Unit Test
  • Manual test (add detailed scripts or steps below)
  • No need to test or manual test. Reason: regression-test-only change.

With the nereids distribute planner on, the join in this suite can be planned
either as a partitioned shuffle or as a left-to-right bucket shuffle (the left
aggregated side shuffled onto the right table's storage buckets), and the two
candidates are chosen by cost. That cost depends on two things that are not
stable during the test:

- the scan row count, which is reported asynchronously after the insert, so an
  unreported count clamps to 1 and yields a partitioned shuffle, while the real
  count yields a bucket shuffle;
- the bucket-shuffle downgrade gate, which turns bucket shuffle back into a
  partitioned shuffle when the bucket count is small relative to the instance
  count, so the plan also depends on the number of backends.

As a result the asserted plan flipped between INNER JOIN(PARTITIONED) and
INNER JOIN(BUCKET_SHUFFLE) depending on timing and cluster topology.

The suite is meant to assert the left-to-right bucket shuffle, which saves one
exchange versus a plain partitioned shuffle. Restore that assertion and make it
deterministic:

- analyze the table with sync so the row count is fixed instead of racing the
  async tablet report;
- set bucket_shuffle_downgrade_ratio=0 so the plan does not depend on the number
  of backends.
@hello-stephen

Copy link
Copy Markdown
Contributor

Thank you for your contribution to Apache Doris.
Don't know what should be done next? See How to process your PR.

Please clearly describe your PR:

  1. What problem was fixed (it's best to include specific error reporting information). How it was fixed.
  2. Which behaviors were modified. What was the previous behavior, what is it now, why was it modified, and what possible impacts might there be.
  3. What features were added. Why was this function added?
  4. Which code was refactored and why was this part of the code refactored?
  5. Which functions were optimized and what is the difference before and after the optimization?

@924060929

Copy link
Copy Markdown
Contributor Author

run buildall

@924060929

Copy link
Copy Markdown
Contributor Author

/review

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Automated review completed for e33826582d27a50d94187db8af1ab03e96194b80. I found no blocking or correctness issues.

Checkpoint conclusions:

  • Goal and proof: The change addresses the stated timing/topology flake. Synchronous full analysis publishes the measured three-row base-index count and id2 NDV before either EXPLAIN, while bucket_shuffle_downgrade_ratio=0 removes the instance-count downgrade. The suite still proves the legacy PARTITIONED/two-exchange plan, now proves the distribute-planner BUCKET_SHUFFLE/one-exchange plan, and checks identical ordered query results.
  • Scope and clarity: The patch is focused on one regression suite and adds only the two determinism inputs, the corrected assertion, and explanatory comments.
  • Concurrency and lifecycle: No production concurrency or lifecycle logic changes. The existing synchronous analysis task fan-out waits on all tasks and uses concurrent/synchronized publication paths. The regression framework closes the suite JDBC context, so the session-variable override does not leak to other suites.
  • Configuration and parallel paths: No configuration item is added. The existing forwarded session variable documents that values <= 0 disable downgrade. The distribute planner exposes both shuffle directions and strictly prefers the smaller one-column aggregate exchange; the legacy planner short-circuits to its existing partitioned path, so setting the ratio before both legs is safe.
  • Compatibility, persistence, and data correctness: No storage format, symbol, FE-BE protocol, EditLog, transaction implementation, or compatibility behavior changes. The setup insert is committed and synchronized before analysis, and analysis failures propagate instead of silently changing the asserted plan.
  • Test quality and results: The plan labels and exchange counts are asserted, both result checks remain ordered, the table is dropped before creation and retained for debugging, and the unchanged generated .out remains correct. The PR reports three successful runs on a four-backend cluster. Per the review-runner contract, I performed static review and did not run builds or regression tests locally.
  • Performance and observability: The added full analysis scans only a three-row/two-column test table and adds no production overhead. Existing EXPLAIN, variable, and row logging is sufficient for diagnosing this regression.
  • Other review points: No additional negative test, metric, lock, memory-ownership, cloud/shared-nothing, or rolling-upgrade work is applicable to this test-only stabilization.

User focus: no additional focus points were provided; the complete PR was reviewed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants